﻿using System;
using System.Windows;
using System.Windows.Controls;
using ShellLight.Contract;
using ShellLight.Contract.Events;
using ShellLight.ModuleExample.Commands;
using ShellLight.ModuleExample.Events;

namespace ShellLight.ModuleExample.Views
{
    public partial class TestView2 : UserControl
    {
        private readonly UICommandContext context;

        public TestView2()
        {
            InitializeComponent();
        }

        public TestView2(UICommandContext context):this()
        {
            this.context = context;
            context.Events.GetEvent<SomethingUpdatedEvent>().Subscribe(SomethingUpdatedHandler);
        }

        public void SomethingUpdatedHandler(Something obj)
        {
            this.textBox.Text = "Test Event 1 raised - do something!";
        }

        private void Button_Click(object sender, RoutedEventArgs e)
        {
            var command = context.LookUpCommand<TestModalUICommand>();
            command.Show();
        }
    }
}


